package com.santalu.myapplication;

import com.santalu.emptyview.LogUtil;
import com.santalu.emptyview.PixelUtil;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.app.Context;
import org.junit.Assert;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * @author hw
 * @since 2021/5/27
 */
public class ExampleUnitTest {
    Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();

    /**
     * 单元测试1
     */
    @Test
    public void addition_isCorrect() {
        assertEquals(4, 2 + 2);
    }

    /**
     * 单元测试1
     */
    @Test
    public void PixelUtil_fp2px() {
        PixelUtil.initContext(context);
        float px_turn = PixelUtil.fp2px(15);
        Assert.assertEquals(45.0, px_turn, 0.0);
    }

    /**
     * 单元测试1
     */
    @Test
    public void PixelUtil_vp2px() {
        PixelUtil.initContext(context);
        float px_turn = PixelUtil.vp2px(15);
        Assert.assertEquals(45.5, px_turn, 0.0);
    }

    /**
     * 单元测试1
     */
    @Test
    public void PixelUtil_screenWidth() {
        PixelUtil.initContext(context);
        int width = PixelUtil.screenWidth();
        Assert.assertTrue(width > 0);
    }

    /**
     * 单元测试1
     */
    @Test
    public void PixelUtil_screenHeight() {
        PixelUtil.initContext(context);
        int height = PixelUtil.screenHeight();
        Assert.assertTrue(height > 0);
    }
}